<?php
namespace app\serverfund\validate;
use \app\manage\validate\BaseValidate;
/**
 * @author:      李颖
 * @DateTime:    2017-06-28 13:39:55
 * @Description: 验证积分传入的数据
 */
class IntegralAccount extends BaseValidate
{

    protected $rule = [
        'user_id' => ['integer', 'gt' => '0'],
        'obj_id' => ['integer', 'gt' => '0'],
        'create_ip' => ['ip'],
        'update_ip' => ['ip'],
        'app_id' => ['integer', 'gt' => '0'],
        'integral' => ['integer', 'gt' => '0'],
        'opposite_id' => ['integer', 'gt' => '0', 'different' => 'user_id'],
        'freeze_log_id' => ['integer', 'gt' => '0'],
        'user_ids' => ['length'=>'1,256'],
        'exchange' => ['in'=>'Currency,Fund'],
        'money' => ['float', 'egt' => '0'],
        'currency_scale' => ['float','gt'=>'0','requireIf'=>'exchange,Currency'],
        'user_info' => ['regex'=>'^{.*}$'],
        'opposite_info' => ['regex'=>'^{.*}$'],
        'type' => ['in'=>'goods,certificate,order,integral_order'],
        'obj_id' => ['integer', 'gt'=>'0'],
        'user_available_integral' => ['integer', 'egt'=>'0'],
        'order_max_integral_deduction' => ['integer', 'egt'=>'0'],
        'order_total_price' => ['number', 'gt'=>'0'],
        'order_currency_total_price' => ['number', 'egt'=>'0'],
        'fund_type' => ['in'=>'money,currency'],
        'reason' => ['min'=>5],
        'user_infos' => ['array', 'min'=>1]
    ];
    protected $message = [];
    protected $scene = [
        'init' => ['user_id', 'create_ip', 'app_id'],
        'prepaid' => ['user_id', 'integral', 'update_ip', 'app_id', 'user_info', 'opposite_info'],
        'prepaidByUids' => ['integral', 'update_ip', 'app_id', 'user_infos'],
        'transfer' => ['user_id', 'opposite_id', 'integral', 'update_ip', 'app_id', 'user_info', 'opposite_info'],
        'freeze' => ['user_id', 'opposite_id', 'integral', 'update_ip', 'app_id', 'borrow_log_id', 'freeze_log_id', 'user_info', 'opposite_info','type','obj_id'],
        'unfreeze' => ['user_id', 'opposite_id', 'integral', 'update_ip', 'app_id', 'borrow_log_id', 'freeze_log_id', 'user_info', 'opposite_info'],
        'list' => ['page', 'list_rows'],
        'listByUserIds' => ['user_ids'],
        'exchange' => ['exchange', 'money','app_id','currency_scale'],
    ];
}
